package com.iccct.elastic.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;

/**
 * @author iccct
 * @date 2021/11/15 16:42
 */
public class ElasticsearchRestTemplateConfig extends AbstractElasticsearchConfiguration {

    @Value("spring.elasticsearch.rest.uris")
    private String uri;

    @Override
    public RestHighLevelClient elasticsearchClient() {
        ClientConfiguration configuration = ClientConfiguration.builder()
                .connectedTo(uri)
                .build();
        return RestClients.create(configuration).rest();
    }
}
